//
//  ICMCellContentView.m
//  ICrEAM
//
//  Created by rainimute on 16/11/22.
//  Copyright © 2016年 mac. All rights reserved.
//

#import "ICMCellContentView.h"

@implementation ICMCellContentView

+ (instancetype)createCellContentViewWithProxyActivityViewModel:(ICMProxyActivityViewModel *)viewModel andFrame:(CGRect)frame{
    return [[ICMCellContentView alloc]initWithProxyActivityViewModel:viewModel andFrame:frame];
}

- (instancetype)initWithProxyActivityViewModel:(ICMProxyActivityViewModel *)viewModel andFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = [UIColor colorWithRed:0.95f green:0.95f blue:0.95f alpha:1.00f];
        [self setupCellContentViewWithProxyActivityViewModel:viewModel];
    }
    return self;
}

#pragma mark 根据model设值
- (void)setupCellContentViewWithProxyActivityViewModel:(ICMProxyActivityViewModel *)viewModel{
    self.activityNameLabel.text = viewModel.title;
    self.subNameLabel.text = viewModel.subTitle;
    self.startTimeLabel.text = viewModel.startTime;
    self.endTimeLabel.text = viewModel.endTime;
    self.stateButton.selected = viewModel.isSelected;
    self.rotateButton.selected = viewModel.isRotation;
}

- (void)stateButttonAction:(UIButton*)sender{
    if ([self.delegate respondsToSelector:@selector(didSelected)]) {
        [self.delegate didSelected];
    }
}

- (void)rotateButtonAction:(UIButton*)sender{
    if ([self.delegate respondsToSelector:@selector(didSelectedRotateButton)]) {
        [self.delegate didSelectedRotateButton];
    }
}

/****init******/

- (UIButton *)stateButton{
    if (!_stateButton) {
        _stateButton = [[UIButton alloc]initWithFrame:CGRectMake(ActualWidth(56), ActualHeight(40), ActualWidth(20), ActualHeight(20))];
        [_stateButton setUpButtonWithNormolTitle:nil selectedTitle:nil normolTitleSize:0 selectedTitleSize:0 normolTitleColor:nil selectedTitleColor:nil normolBcakImage:[UIImage imageNamed:@"btn_activity_notchoose"] selectedBackImage:[UIImage imageNamed:Appointment_ActivityChoose] actionSEL:@selector(stateButttonAction:) target:self];
        [self addSubview:_stateButton];
    }
    return _stateButton;
}

- (UILabel *)activityNameLabel{
    if (!_activityNameLabel) {
        _activityNameLabel = [[UILabel alloc]initWithFrame:CGRectMake(ActualWidth(125), 0, ActualWidth(675), ActualHeight(50))];
        [_activityNameLabel setUpLabelWithText:@"" alignment:NSTextAlignmentLeft textSize:22 textColor:[UIColor blackColor]];
        [self addSubview:_activityNameLabel];
    }
    return _activityNameLabel;
}

- (UILabel *)subNameLabel{
    if (!_subNameLabel) {
        _subNameLabel = [[UILabel alloc]initWithFrame:CGRectMake(ActualWidth(125), ActualHeight(50), ActualWidth(675), ActualHeight(50))];
        [_subNameLabel setUpLabelWithText:@"" alignment:NSTextAlignmentLeft textSize:14 textColor:[UIColor blackColor]];
        [self addSubview:_subNameLabel];
    }
    return _subNameLabel;
}

- (UILabel *)startTimeLabel{
    if (!_startTimeLabel) {
        _startTimeLabel = [[UILabel alloc]initWithFrame:CGRectMake(ScreenWidth-ActualWidth(300), ActualHeight(25), ActualWidth(225), ActualHeight(25))];
        [_startTimeLabel setUpLabelWithText:@"" alignment:NSTextAlignmentCenter textSize:14 textColor:[UIColor blackColor]];
        [self addSubview:_startTimeLabel];
    }
    return _startTimeLabel;
}

- (UILabel *)endTimeLabel{
    if (!_endTimeLabel) {
        _endTimeLabel = [[UILabel alloc]initWithFrame:CGRectMake(ScreenWidth-ActualWidth(300), ActualHeight(50), ActualWidth(225), ActualHeight(25))];
        [_endTimeLabel setUpLabelWithText:@"" alignment:NSTextAlignmentCenter textSize:14 textColor:[UIColor blackColor]];
        [self addSubview:_endTimeLabel];
    }
    return _endTimeLabel;
}

- (UIButton *)rotateButton{
    if (!_rotateButton) {
        _rotateButton = [[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth-ActualWidth(60), ActualHeight(30), ActualWidth(40), ActualHeight(40))];
        [_rotateButton setUpButtonWithNormolTitle:nil selectedTitle:nil normolTitleSize:0 selectedTitleSize:0 normolTitleColor:nil selectedTitleColor:nil normolBcakImage:[UIImage imageNamed:GetCar_Expand] selectedBackImage:[UIImage imageNamed:@"收起"] actionSEL:@selector(rotateButtonAction:) target:self];
        [self addSubview:_rotateButton];
    }
    return _rotateButton;
}


@end
